#[tauri::command]
pub fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[tauri::command]
pub async fn close_window(window: tauri::Window) {
    println!("关闭了");
    #[cfg(not(any(target_os = "android", target_os = "ios")))] // 仅在非 Android 和非 iOS 平台生效
    window.close().expect("Failed to close window");
}

#[tauri::command]
pub async fn minimize_window(window: tauri::Window) {
    println!("最小化");
    #[cfg(not(any(target_os = "android", target_os = "ios")))] // 仅在非 Android 和非 iOS 平台生效
    window.minimize().expect("Failed to minimize window");
}

#[tauri::command]
pub async fn maximize_window(window: tauri::Window) {
    println!("最大化");
    #[cfg(not(any(target_os = "android", target_os = "ios")))] // 仅在非 Android 和非 iOS 平台生效
    {
        let is_maximized = window.is_maximized().unwrap();
        if is_maximized {
            window.unmaximize().expect("Failed to unmaximize window");
        } else {
            window.maximize().expect("Failed to maximize window");
        }
    }
}

#[tauri::command]
pub async fn toggle_minimize(window: tauri::Window) {
    println!("最小化切换");
    #[cfg(not(any(target_os = "android", target_os = "ios")))] // 仅在非 Android 和非 iOS 平台生效
    {
        let is_visible = window.is_visible().unwrap_or(true);
        if is_visible {
            window.minimize().expect("Failed to minimize window");
        }
    }
}